﻿@page "/weeklynews"

@inject IHttpService _httpService
@inject IDataCacheService _dataCacheService
@inject IPageModelCatche<List<ArticleInforTipViewModel>>  _pageModelCatche

@if (isReady)
{
    @if (_dataCacheService.IsApp)
    {
        <CnGalWebSite.Shared.Pages.Apps.Home.About Index="@(_items.FirstOrDefault()?.Id??281)" />

    }
    else
    {
        <CnGalWebSite.Shared.MasaComponent.PC.Home.Documents.IndexPage Id="@(_items.FirstOrDefault()?.Id??281)" />
    }
}

@code{
    [CascadingParameter]
    public ErrorHandler ErrorHandler { get; set; }

    bool isReady;

    List<ArticleInforTipViewModel> _items;

    protected override async Task OnInitializedAsync()
    {

        try
        {
            _items = await _pageModelCatche.GetCache("api/news/GetWeeklyNewsOverview");

            isReady = true;
        }
        catch (Exception ex)
        {
            await ErrorHandler.ProcessError(ex, "获取周报列表失败");
        }
    }
}
